home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Other Stuff / Demos ƒ / Demo AppMaker / Demo AppMaker™ / Demo AppMaker™.rsrc / TmpP_104_MainMenu < prev    next >
Encoding:
Text File  |  1990-03-23  |  2.8 KB  |  155 lines

  1. { %filename% }
  2. { Created %date% %time% by AppMaker }
  3.  
  4. Unit %unitname%;
  5. Interface
  6.  
  7. Uses
  8. %if lang = MPW%
  9.     {$Load ToolBox.dump}
  10.         MemTypes,
  11.         QuickDraw,
  12.         OSIntf,
  13.         ToolIntf,
  14.         PackIntf,
  15.     {$Load}
  16.  
  17. %end if%
  18. %if lang = Think%
  19. {$ifc undefined Think_Pascal}
  20.     ListManager,
  21. {$endc}
  22. %end if%
  23.     %for each menu gen uses%
  24.     Globals,
  25.     ResourceDefs;
  26.     
  27. {----------}
  28. Procedure InitTitles;
  29. Procedure LoadMenus;
  30. Procedure DoMenu (menuChoice:    longint);
  31. Procedure UpdateMenus;
  32.  
  33. {----------}
  34. Implementation
  35.  
  36. %if lang = MPW%
  37. {$D+}
  38. {$R+}
  39. {$OV+}
  40.  
  41. %end if%
  42. %if lang = MPW%
  43. {$S %unitname%}
  44.  
  45. %end if%
  46. {----------}
  47. Procedure InitTitles;
  48. Begin
  49.     %for each menu gen initTitles%
  50. End; {InitTitles}
  51.  
  52. {----------}
  53. Procedure LoadMenus;
  54. Begin
  55.     %for each menu gen get%
  56.     %for each menu gen insert% 
  57.     DrawMenuBar;
  58. End; {LoadMenus}
  59.  
  60. %for each menu gen doApple%
  61. {----------}
  62. Procedure DoMenu {(menuChoice:    longint)};
  63. var
  64.     menuID:            integer;
  65.     itemNr:            integer;
  66. Begin
  67.     menuID := HiWord (menuChoice);
  68.     itemNr := LoWord (menuChoice);
  69.     
  70.     case menuID of
  71.         0:
  72.                 {Do nothing};
  73.         %for each menu gen dispatch%
  74.     end; {case}
  75.  
  76.     HiliteMenu (0);
  77. End; {DoMenu}
  78.  
  79. {----------}
  80. Procedure UpdateMenus;
  81. var
  82.     frontPeek:        WindowPeek;
  83.     isFront:        boolean;    {is there a front window?}
  84.     isCur:            boolean;    {is there a current window?}
  85.     isDirty:        boolean;    {is it dirty?}
  86.     hasFile:        boolean;    {does it have a file?}
  87.     isSelected:        boolean;    {is anything selected?}
  88.     isDesk:            boolean;    {is the front window a desk acc?}
  89.     isText:            boolean;    {is there a current text field?}
  90.     isScrap:        boolean;    {is there any scrap?}
  91.     menu:            MenuHandle;
  92.     menuBarChanged:    boolean;
  93.     
  94.     {----------}
  95.     Procedure Enable (itemNr:    integer;
  96.                       enabled:    boolean);
  97.     Begin
  98.         if enabled then begin
  99.             EnableItem  (menu, itemNr);
  100.         end else begin
  101.             DisableItem (menu, itemNr);
  102.         end;
  103.     End; {Enable}
  104.     
  105.     {----------}
  106.     Procedure EnableTitle (menu:    MenuHandle;
  107.                              enabled:    boolean);
  108.     Begin
  109.         if enabled <> odd (menu^^.enableFlags) then begin
  110.             menuBarChanged := true;
  111.         end;
  112.         if enabled then begin
  113.             EnableItem  (menu, 0);
  114.         end else begin
  115.             DisableItem (menu, 0);
  116.         end;
  117.     End; {EnableTitle}
  118.     
  119. Begin {UpdateMenus}
  120.  
  121.     menuBarChanged := false;
  122.  
  123.     isFront        := (FrontWindow <> nil);
  124.     isCur        := (curWindow <> nil);
  125.     isDirty     := false;
  126.     hasFile     := false;
  127.     isSelected    := false;
  128.     if isCur then begin
  129.         isDirty        :=  cur^.dirty;
  130.         hasFile        := (cur^.fileNum <> 0);
  131.     end;
  132.  
  133.     isDesk := false;
  134.     if isFront then begin
  135.         frontPeek    := WindowPeek (FrontWindow);
  136.         isDesk        := (frontPeek^.windowKind < 0);
  137.     end;
  138.     isText        := false;
  139.     if isCur then begin
  140.         isText        := (cur^.text <> nil);
  141.     end;
  142.     isScrap        := false;
  143.     if isText then begin
  144.         isSelected    := (cur^.text^^.selStart <> cur^.text^^.selEnd);
  145.         isScrap        := (TEGetScrapLen > 0);
  146.     end;
  147.     
  148.     %for each menu gen enable%
  149.     if menuBarChanged then begin
  150.         DrawMenuBar;
  151.     end;
  152. End; {UpdateMenus}
  153.  
  154. End. {%unitname%}
  155.